package com.project.util;

import java.util.List;

import javax.servlet.ServletContext;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.ServletContextAware;

import com.project.entity.sys.SysMenu;
import com.project.service.sys.MenuService;

public class ServletContextUtil implements InitializingBean, ServletContextAware{

	private static ServletContext servletContext; 
	
	@Autowired
	private MenuService menuService;
	
	
	private static final String[] color = new String[]{"primary","info","success","warning","danger","inverse","pink","purple","yellow","grey","light"};
    
	@Override
	public void setServletContext(ServletContext servletContext) {
		// TODO Auto-generated method stub
		List<SysMenu> firstMenu = menuService.getFirstMenu();
		servletContext.setAttribute("menu", firstMenu);
		servletContext.setAttribute("color", color);
		ServletContextUtil.servletContext = servletContext;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		
		
	}
	
	public static ServletContext getServletContext()
	{
		return servletContext;
	}


}
